package com.shiyi.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;

/**
 * 工厂
 */
@Service
public class PayFactory {
    // payType 哪个具体策略服务
    @Autowired
    private ApplicationContext applicationContext;

    private List<PayServiceAbstract> list = new ArrayList<>();
    public PayServiceAbstract getFactory(String payType){

        try {
            Class<?> aClass = Class.forName("com.shiyi.controller.WxPayServiceAbstractImpl");
            PayServiceAbstract o = (PayServiceAbstract) aClass.newInstance();
            list.add(o);
//            PayServiceAbstract service = (PayServiceAbstract) applicationContext.getBean(payType);
            return o;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
